.class public Lcom/netease/mobistat/client/clients/WhoAmIClient;
.super Lcom/netease/mobistat/client/clients/BaseClient;
.source "WhoAmIClient.java"


# instance fields
.field private globalIP:Ljava/lang/String;


# direct methods
.method public constructor <init>()V
    .locals 2

    .prologue
    .line 26
    const-string v0, "mt.c.3g.163.com"

    const/16 v1, 0x138a

    invoke-direct {p0, v0, v1}, Lcom/netease/mobistat/client/clients/BaseClient;-><init>(Ljava/lang/String;I)V

    .line 27
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;I)V
    .locals 0
    .parameter "server"
    .parameter "port"

    .prologue
    .line 30
    invoke-direct {p0, p1, p2}, Lcom/netease/mobistat/client/clients/BaseClient;-><init>(Ljava/lang/String;I)V

    .line 31
    return-void
.end method


# virtual methods
.method public getGlobalIP()Ljava/lang/String;
    .locals 1

    .prologue
    .line 34
    iget-object v0, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->globalIP:Ljava/lang/String;

    return-object v0
.end method

.method public run()V
    .locals 8

    .prologue
    const/4 v7, 0x1

    .line 40
    new-instance v0, Lorg/jboss/netty/bootstrap/ClientBootstrap;

    new-instance v4, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory;

    .line 41
    invoke-static {}, Ljava/util/concurrent/Executors;->newCachedThreadPool()Ljava/util/concurrent/ExecutorService;

    move-result-object v5

    invoke-static {}, Ljava/util/concurrent/Executors;->newCachedThreadPool()Ljava/util/concurrent/ExecutorService;

    move-result-object v6

    invoke-direct {v4, v5, v6}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory;-><init>(Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)V

    .line 40
    invoke-direct {v0, v4}, Lorg/jboss/netty/bootstrap/ClientBootstrap;-><init>(Lorg/jboss/netty/channel/ChannelFactory;)V

    .line 44
    .local v0, bootstrap:Lorg/jboss/netty/bootstrap/ClientBootstrap;
    iget v4, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->port:I

    invoke-static {v4}, Lcom/netease/mobistat/client/pipeline/PipelineFactoryFactory;->createPipelineFactory(I)Lorg/jboss/netty/channel/ChannelPipelineFactory;

    move-result-object v4

    invoke-virtual {v0, v4}, Lorg/jboss/netty/bootstrap/ClientBootstrap;->setPipelineFactory(Lorg/jboss/netty/channel/ChannelPipelineFactory;)V

    .line 45
    const-string v4, "tcpNoDelay"

    invoke-static {v7}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v5

    invoke-virtual {v0, v4, v5}, Lorg/jboss/netty/bootstrap/ClientBootstrap;->setOption(Ljava/lang/String;Ljava/lang/Object;)V

    .line 46
    const-string v4, "keepAlive"

    invoke-static {v7}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v5

    invoke-virtual {v0, v4, v5}, Lorg/jboss/netty/bootstrap/ClientBootstrap;->setOption(Ljava/lang/String;Ljava/lang/Object;)V

    .line 49
    new-instance v4, Ljava/net/InetSocketAddress;

    iget-object v5, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->server:Ljava/lang/String;

    iget v6, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->port:I

    invoke-direct {v4, v5, v6}, Ljava/net/InetSocketAddress;-><init>(Ljava/lang/String;I)V

    invoke-virtual {v0, v4}, Lorg/jboss/netty/bootstrap/ClientBootstrap;->connect(Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v2

    .line 52
    .local v2, future:Lorg/jboss/netty/channel/ChannelFuture;
    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->awaitUninterruptibly()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v4

    invoke-interface {v4}, Lorg/jboss/netty/channel/ChannelFuture;->getChannel()Lorg/jboss/netty/channel/Channel;

    move-result-object v4

    iput-object v4, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->channel:Lorg/jboss/netty/channel/Channel;

    .line 53
    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->isSuccess()Z

    move-result v4

    if-nez v4, :cond_0

    .line 54
    invoke-interface {v2}, Lorg/jboss/netty/channel/ChannelFuture;->getCause()Ljava/lang/Throwable;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/Throwable;->printStackTrace()V

    .line 55
    invoke-virtual {v0}, Lorg/jboss/netty/bootstrap/ClientBootstrap;->releaseExternalResources()V

    .line 70
    :goto_0
    return-void

    .line 61
    :cond_0
    :try_start_0
    iget-object v4, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->channel:Lorg/jboss/netty/channel/Channel;

    invoke-interface {v4}, Lorg/jboss/netty/channel/Channel;->getPipeline()Lorg/jboss/netty/channel/ChannelPipeline;

    move-result-object v4

    invoke-interface {v4}, Lorg/jboss/netty/channel/ChannelPipeline;->getLast()Lorg/jboss/netty/channel/ChannelHandler;

    move-result-object v3

    check-cast v3, Lcom/netease/mobistat/client/Handler/WhoAmIClientHandler;

    .line 62
    .local v3, handler:Lcom/netease/mobistat/client/Handler/WhoAmIClientHandler;
    invoke-virtual {v3}, Lcom/netease/mobistat/client/Handler/WhoAmIClientHandler;->getGlobalIP()Ljava/lang/String;

    move-result-object v4

    iput-object v4, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->globalIP:Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 68
    .end local v3           #handler:Lcom/netease/mobistat/client/Handler/WhoAmIClientHandler;
    :goto_1
    iget-object v4, p0, Lcom/netease/mobistat/client/clients/WhoAmIClient;->channel:Lorg/jboss/netty/channel/Channel;

    invoke-interface {v4}, Lorg/jboss/netty/channel/Channel;->getCloseFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v4

    invoke-interface {v4}, Lorg/jboss/netty/channel/ChannelFuture;->awaitUninterruptibly()Lorg/jboss/netty/channel/ChannelFuture;

    .line 69
    invoke-virtual {v0}, Lorg/jboss/netty/bootstrap/ClientBootstrap;->releaseExternalResources()V

    goto :goto_0

    .line 64
    :catch_0
    move-exception v1

    .line 65
    .local v1, e:Ljava/lang/Exception;
    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_1
.end method
